//
//  ZPUrlTransverter.m
//  ZhenPin
//
//  Created by fei on 14-7-21.
//  Copyright (c) 2014年 zhenpin. All rights reserved.
//

#import "ZPUrlTransverter.h"

@implementation ZPUrlTransverter
+(NSURL *)transToImageUrlWithString:(NSString *)oldString insertImageSize:(int)size {
    NSString *newString;
//    if ([oldString hasSuffix:@".JPG"] || [oldString hasSuffix:@".jpg"]) {
        if ([oldString isEqual:[NSNull null]] || oldString.length <= 0) {
            
        } else {
            NSMutableArray *array = [NSMutableArray arrayWithArray:[oldString componentsSeparatedByString:@"/"]];
            if (array.count > 0) {
                NSMutableString *lastStr = [NSMutableString stringWithString:[array lastObject]];
                [lastStr insertString:[NSString stringWithFormat:@"%d_",size] atIndex:0];
                [array replaceObjectAtIndex:array.count-1 withObject:lastStr];
                
                newString = [array componentsJoinedByString:@"/"];
            }
            
        }
//        
//    } else {
//        newString = oldString;
//    }
    return [NSURL URLWithString:newString];
}
@end
